package com.techstar.ats.codec.live.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.DateTimeCodec;
import com.techstar.ats.codec.MessageDecoder;
import com.techstar.ats.dxp.live.F07Depot;
import com.techstar.ats.dxp.live.rep.F07DepotPlan;

public enum F07DepotPlanDecoder implements MessageDecoder<F07DepotPlan> {
	INSTANCE;

	public F07DepotPlan create() {
		return new F07DepotPlan();
	}

	public void decode(ByteBuf buf, F07DepotPlan value) {
		value.line = buf.readUnsignedShort();
		value.datetime = DateTimeCodec.INSTANCE.get(buf);
		int cnt = buf.readUnsignedShort();

		for(int i = 0; i < cnt; ++i) {
			F07Depot depot = F07DepotDecoder.INSTANCE.create();
			F07DepotDecoder.INSTANCE.decode(buf, depot);
			value.depots.add(depot);
		}
	}
}
